package com.ruoyi.web.mapper;

import com.ruoyi.admin.domain.Sensor;
import org.apache.ibatis.annotations.*;

public interface dataMapper {

    @Insert("INSERT INTO sensor (name, temperature, humidity, soil_n, soil_k, soil_p, timestamp) " +
            "VALUES (#{name}, #{temperature}, #{humidity}, #{soilN}, #{soilK}, #{soilP}, #{timestamp})")
    void insertSensor(Sensor sensor);

    @Update("UPDATE sensor SET name = #{name}, temperature = #{temperature}, humidity = #{humidity}, " +
            "soil_n = #{soilN}, soil_k = #{soilK}, soil_p = #{soilP}, timestamp = #{timestamp} " +
            "WHERE id = #{id}")
    void updateSensor(Sensor sensor);

    @Select("SELECT * FROM sensor WHERE id = #{id}")
    Sensor selectSensorById(Long id);

}
